package com.wufeng.mycode;

public class ChangeVlaue {
    public static void main(String[] args) {
        ChangeVlaue change = new ChangeVlaue();
        //change value 基本类型
        int age = 18;
        System.out.println("age is : " + age);
        change.changeValue(age);
        System.out.println("age is : " + age);
        //change value 自定义对象
        Person person = new Person("name");
        System.out.println(person.toString());
        change.changeValue(person);
        System.out.println(person.toString());
        //change value String 对象
        String str = "value";
        System.out.println("str is : " + str);
        change.changeValue(str);
        System.out.println("str is : " + str);
    }

    public void changeValue(int age) {
        age = 30;
    }

    public void changeValue(String str) {
        str = "changeValue";
    }

    public void changeValue(Person person) {
        person.setName("changeName");
    }

}

class Person {
    private int id;
    private String name;

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }

    Person(String name) {
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
